/* model manager */
.model-manager {
    background-color: var(--comfy-menu-bg);
    box-sizing: border-box;
    color: var(--bg-color);
    font-family: monospace;
    font-size: 15px;
    height: 100%;
    padding: 8px;
    position: fixed;
    overflow: hidden;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 2000;
    
    /*override comfy-modal settings*/
    border-radius: 0;
    box-shadow: none;
    justify-content: unset;
    max-height: unset;
    max-width: unset;
    transform: none;
}

.model-manager .comfy-modal-content {
    width: 100%;
    gap: 16px;
}

.model-manager.sidebar-left {
    width: 50%;
    left: 0%;
}

.model-manager.sidebar-top {
    height: 50%;
    top: 0%;
}

.model-manager.sidebar-bottom {
    height: 50%;
    top: 50%;
}

.model-manager.sidebar-right {
    width: 50%;
    left: 50%;
}

.model-manager .sidebar-buttons .sidebar-button-active {
    border-color: var(--fg-color);
    color: var(--fg-color);
    overflow: hidden;
}

/* common */
.model-manager h1 {
    min-width: 0;
    overflow-wrap: break-word;
}

.model-manager textarea {
    border: solid 2px var(--border-color);
    border-radius: 8px;
    font-size: 1.2em;
    resize: vertical;
    width: 100%;
}

.model-manager input[type="file"] {
    width: 100%;
}

.model-manager button,
.model-manager select,
.model-manager input {
    padding: 4px 8px;
    margin: 0;
	border: 2px solid var(--border-color);
}

.model-manager button:disabled,
.model-manager select:disabled,
.model-manager input:disabled {
    background-color: var(--comfy-menu-bg);
    filter: brightness(1.2);
    cursor: not-allowed;
}

.model-manager button.block {
    width: 100%;
}

.model-manager ::-webkit-scrollbar {
    width: 16px;
}

.model-manager ::-webkit-scrollbar-track {
    background-color: var(--comfy-input-bg);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.model-manager ::-webkit-scrollbar-thumb {
    background-color: var(--fg-color);
    border-radius: 3px;
}

.model-manager .search-text-area::-webkit-input-placeholder {
   font-style: italic;
}
.model-manager .search-text-area:-moz-placeholder {
   font-style: italic;  
}
.model-manager .search-text-area::-moz-placeholder {
   font-style: italic;  
}
.model-manager .search-text-area:-ms-input-placeholder {  
   font-style: italic; 
}

.model-manager .icon-button {
    height: 40px;
    width: 40px;
    line-height: 1.15;
}

.model-manager .row {
    display: flex;
    min-width: 0;
    gap: 8px;
}

.model-manager .tab-header {
    display: flex;
    padding: 8px 0;
    flex-direction: column;
    background-color: var(--bg-color);
}

.model-manager .tab-header-flex-block {
	width: 100%;
    min-width: 0;
}

.model-manager .button-success {
    color: green;
    border-color: green;
}

.model-manager .button-failure {
    color: darkred;
    border-color: darkred;
}

.model-manager .no-select {
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* sidebar buttons */
.model-manager .sidebar-buttons {
    overflow: hidden;
    color: var(--input-text);
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap;
}

/* main content */
.model-manager .model-manager-panel {
    color: var(--fg-color);
}

.model-manager .model-manager-tabs {
    display: flex;
    gap: 4px;
    height: 40px;
}

.model-manager .model-manager-tabs .head-item {
    background-color: var(--comfy-menu-bg);
    border: 2px solid var(--border-color);
    border-bottom: none;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    cursor: pointer;
    padding: 8px 12px;
    margin-bottom: 0px;
    z-index: 1;
}

.model-manager .model-manager-tabs .head-item.active {
    background-color: var(--bg-color);
    cursor: default;
    position: relative;
    z-index: 1;
}

.model-manager .model-manager-body {
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: 16px 0px;
}

.model-manager .model-manager-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.model-manager .model-manager-body {
    flex: 1;
    overflow: hidden;
}

.model-manager .model-manager-body > div {
    position: relative;
    height: 100%;
    width: auto;
    padding: 0 16px;
    overflow-x: auto;
}

/* model info view */
.model-manager .model-info-view {
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-wrap: break-word;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

.model-manager .model-info-container {
    background-color: var(--bg-color);
    border-radius: 16px;
    color: var(--fg-color);
    width: auto;
}

/* download tab */

.model-manager .download-model-infos {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    row-gap: 10px;
}

.model-manager .download-details summary {
    background-color: var(--comfy-menu-bg);
    border-radius: 16px;
    padding: 16px;
    word-wrap: break-word;
}

.model-manager .download-details[open] summary {
    background-color: var(--border-color);
}

.model-manager .download-details > div {
    column-gap: 8px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
    row-gap: 16px;
}

.model-manager [data-name="Download"] .download-settings-wrapper {
    flex: 1;
}

.model-manager [data-name="Download"] .download-settings {
    display: flex;
    flex-direction: column;
    row-gap: 16px;
}

/* models tab */
.model-manager [data-name="Models"] .row {
    position: sticky;
    z-index: 1;
    top: 0;
}

/* preview image */
.model-manager .item {
    position: relative;
    width: 230px;
    height: 345px;
    text-align: center;
    overflow: hidden;
	border-radius: 8px;
}

.model-manager .item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.model-manager .model-preview-button-left,
.model-manager .model-preview-button-right {
    position: absolute;
    top: 0;
    bottom: 0;
    margin: auto;
    border-radius: 20px;
}

.model-manager .model-preview-button-right {
    right: 4px;
}

.model-manager .model-preview-button-left {
    left: 4px;
}

.model-manager .item .model-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: rgba(0, 0, 0, 0);
}

/* grid */
.model-manager .comfy-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.model-manager .comfy-grid .model-label {
	background-color: #000a;
	width: 100%;
	height: 2.2rem;
	position: absolute;
	bottom: 0;
	text-align: center;
	line-height: 2.2rem;
}

.model-manager .comfy-grid .model-label > p {
	width: calc(100% - 2rem);
	overflow-x: scroll;
	white-space: nowrap;
	display: inline-block;
	vertical-align: middle;
	margin: 0;
}

.model-manager .comfy-grid .model-label {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.model-manager .comfy-grid .model-label ::-webkit-scrollbar { 
    width: 0;
    height: 0;
}

.model-manager .comfy-grid .model-preview-top-right,
.model-manager .comfy-grid .model-preview-top-left {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 8px;
    top: 8px;
}

.model-manager .comfy-grid .model-preview-top-right {
    right: 8px;
}

.model-manager .comfy-grid .model-preview-top-left {
    left: 8px;
}

.model-manager .comfy-grid .model-button {
    opacity: 0.65;
}

.model-manager .comfy-grid .model-button:hover {
    opacity: 1;
}

.model-manager .comfy-grid .model-label {
    user-select: text;
}

/* radio */
.model-manager .comfy-radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.model-manager .comfy-radio {
    display: flex;
    gap: 4px;
    padding: 4px 16px;
    color: var(--input-text);
	border: 2px solid var(--border-color);
    border-radius: 16px;
    background-color: var(--comfy-input-bg);
    font-size: 18px;
}

.model-manager .comfy-radio:has(> input[type="radio"]:checked) {
	border-color: var(--border-color);
	background-color: var(--comfy-menu-bg);
}

.model-manager .comfy-radio input[type="radio"]:checked + label {
	color: var(--fg-color);
}

.model-manager .radio-input {
	opacity: 0;
	position: absolute;
}

/* model preview select */
.model-manager .model-preview-select-radio-container {
    min-width: 0;
    flex: 1;
}

.model-manager .model-preview-select-radio-inputs > div {
    height: 40px;
    padding: 16px 0 8px 0;
}

.model-manager .model-preview-select-radio-container img {
    position: relative;
    width: 230px;
    height: 345px;
    text-align: center;
    overflow: hidden;
	border-radius: 8px;
    object-fit: cover;
}

/* topbar */
.model-manager .topbar-buttons {
    display: flex;
    float: right;
}

.model-manager .topbar-buttons button {
    height: 33px;
    padding: 1px 6px;
    width: 33px;
}

.model-manager .model-manager-head .topbar-left {
    display: flex;
    float: left;
}

.model-manager .model-manager-head .topbar-right {
    column-gap: 4px;
    display: flex;
    flex-direction: row-reverse;
    float: right;
}

/* search dropdown */
.model-manager .search-models {
    display: flex;
    flex: 1;
    flex-direction: row;
    min-width: 0;
}

.model-manager .model-select-dropdown {
    min-width: 0;
    overflow: auto;
}

.model-manager .search-text-area,
.model-manager .plain-text-area,
.model-manager .model-select-dropdown {
	flex: 1;
    min-height: 36px;
    padding-block: 0;
    min-width: 36px;
}

.model-manager .model-select-dropdown {
    min-height: 40px;
}

.model-manager .search-dropdown {
    background-color: var(--bg-color);
    border: 2px var(--border-color) solid;
    border-radius: 10px;
    color: var(--fg-color);
    max-height: 30vh;
    overflow: auto;
    position: absolute;
    z-index: 1;
}

.model-manager .search-dropdown:empty {
    display: none;
}

.model-manager .search-dropdown > p {
    margin: 0;
    padding: 0.85em 20px;
    min-width: 0;
}
.model-manager .search-dropdown > p {
    -ms-overflow-style: none;  /* Internet Explorer 10+ */
    scrollbar-width: none;  /* Firefox */
}
.model-manager .search-dropdown > p::-webkit-scrollbar { 
    display: none;  /* Safari and Chrome */
}

.model-manager .search-dropdown > p.search-dropdown-key-selected,
.model-manager .search-dropdown > p.search-dropdown-mouse-selected {
    background-color: var(--border-color);
}

.model-manager .search-dropdown > p.search-dropdown-key-selected {
    border-left: 1mm solid var(--input-text);
}

/* model manager settings */
.model-manager .model-manager-settings > div,
.model-manager .model-manager-settings > label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
}

.model-manager .model-manager-settings button {
    height: 40px;
    width: 120px;
}

.model-manager .model-manager-settings input[type="number"] {
    width: 50px;
}

.model-manager .search-settings-text {
    width: 100%;
}
